home *** CD-ROM | disk | FTP | other *** search
- /* floating point operations
- 93/12/24 aih created */
-
- #include <SANE.h>
- #include "pstr.h"
- #include "FloatLib.h"
-
- float FloatFromString(const CStr31 str)
- {
- Str31 pstr;
- extended exnum;
- long double ldnum;
-
- c2pstrcpy(pstr, str);
- #if defined(THINK_C) && !__option(mc68881) && __option(native_fp)
- /* see THINK C 5.0 User Manual, p215 */
- ldnum = str2num(pstr);
- #else
- exnum = str2num(pstr);
- x80tox96(&exnum, &ldnum);
- #endif
- return(ldnum);
- }
-
- void FloatToString(float num, CStr31 str, short precision)
- {
- decform form;
- extended exnum;
- long double ldnum;
-
- ldnum = num;
- form.style = 1; /* 0 = " 1.0e+0", 1 = "1.00" */
- form.digits = precision;
- #if defined(THINK_C) && !__option(mc68881) && __option(native_fp)
- /* see THINK C 5.0 User Manual, p215 */
- num2str(&form, num, str);
- #else
- x96tox80(&ldnum, &exnum);
- num2str(&form, exnum, str);
- #endif
- p2cstr((StringPtr) str);
- }
-